<body>
<div class="bjy-admin-nav">
	<i class="fa fa-home"></i> 首页
	&gt;
	会员权益
</div>
<ul id="myTab" class="nav nav-tabs">
   	<li class="active">
		<a href="#home" data-toggle="tab">会员权益列表</a>
   	</li>
   	<li>
		<a href="javascript:;" onclick="add()">添加权益</a>
	</li>
	<li>
		<a href="javascript:;" onclick="edit()">修改会员价格</a>
	</li>
</ul>

	<div id="myTabContent" class="tab-content">
	   <div class="tab-pane fade in active" id="home">
			<table class="table table-striped table-bordered table-hover table-condensed">
				<tr style="text-align:center;">
					<th>内容描述</th>
					<th>操作</th>
				</tr>
				{volist name="data" id="vo"}
					<tr>
						<td>{$vo.contents}</td>
						<td>
							<a href="javascript:;" class="delete" data-id="{$vo.id}">删除</a>
						</td>
					</tr>
				{/volist}
			</table>
	   </div>
	</div>

<!-- 添加会员权益模态框开始 -->
<div class="modal fade" id="bjy-add" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		 <div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title" id="myModalLabel">
					添加会员权益
				</h4>
			</div>
			<div class="modal-body">
				<table class="table table-striped table-bordered table-hover table-condensed">
					<tr>
						<th width="15%">内容描述：</th>
						<td>
							<input class="form-control" type="text" name="content" placeholder="请输入会员权益信息">
						</td>
					</tr>
					<tr>
						<th></th>
						<td>
							<input class="btn btn-success sub-add" type="button" value="添加">
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
</div>
<!-- 添加会员权益模态框结束 -->

<!-- 修改会员价格模态框开始 -->
<div class="modal fade" id="bjy-edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		 <div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
				<h4 class="modal-title" id="myModalLabel">
					修改会员价格
				</h4>
			</div>
			<div class="modal-body">
				<input type="hidden" name="id">
				<table class="table table-striped table-bordered table-hover table-condensed">
					<tr>
						<th style="line-height:34px;width:20%">高级会员(30天)</th>
						<td>
							<input class="form-control" type="text" name="gaoji" value="{$price.gaoji}" onkeyup="checkNum(this)">
						</td>
					</tr>
					<tr>
						<th style="line-height:34px;width:20%">至尊会员(365天)</th>
						<td>
							<input class="form-control" type="text" name="zhizun" value="{$price.zhizun}" onkeyup="checkNum(this)">
						</td>
					</tr>
					<tr>
						<th></th>
						<td>
							<input class="btn btn-success submit-save" type="button" value="修改">
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
</div>
<!-- 修改会员价格模态框结束 -->

<script>
// 添加会员权益内容
function add(){
	$("input[name='content']").val(null);
	$('#bjy-add').modal('show');
}
// 修改会员价格
function edit(obj){
	$('#bjy-edit').modal('show');
}

//检查是否是非数字值  
function checkNum(obj) {  
    if(isNaN(obj.value)){  obj.value = ""; }
    if(obj != null){
        if(obj.value.toString().split(".").length > 1 && obj.value.toString().split(".")[1].length > 2){  
            alert('小数点不能多于两位');
            obj.value = "";  
        }  
    }
}

$(function(){
	/*	会员权益内容删除
	 */
    $('.delete').click(function(){
        if(window.confirm("您确定要删除吗？")){
            $.post("{:url('member_fee_delete')}",{'id':$(this).data('id')},function(data){
                if(data.code){
                    alert('删除成功');
                    window.location.href="{:url('member_fee')}";
                }else{
                    alert(data.msg);
                }
            },'json');
        }
    })
    /*	会员权益内容添加
	 */
    $('.sub-add').click(function(){
        var content = $("input[name='content']").val();
        if(content == ''){
        	alert('请填写会员权益内容！');
        	return false;
        }

        $.post("{:url('member_fee_insert')}",{'content':content},function(data){
            if(data.code){
                alert(data.msg);
                window.location.href="{:url('member_fee')}";
            }else{
                alert(data.msg);
            }
        },'json');
    })

    /*	价格修改
	 */
    $('.submit-save').click(function(){
        var gaoji = $("input[name='gaoji']").val();
        var zhizun = $("input[name='zhizun']").val();
        if(gaoji == ''){
        	alert('请填写高级会员价格！');
        	return false;
        }
        if(zhizun == ''){
        	alert('请填写至尊会员价格！');
        	return false;
        }

        $.post("{:url('member_price')}",{'gaoji':gaoji,'zhizun':zhizun},function(data){
            if(data.code){
                alert(data.msg);
                window.location.href="{:url('member_fee')}";
            }else{
                alert(data.msg);
            }
        },'json');
    })
})
</script>